﻿using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml;

namespace LayeredArchitectureSample.Infrastructure.Services
{
    public class BindingFactory
    {
        public static Binding CreateDefaultBinding()
        {
            return new NetTcpBinding(SecurityMode.None)
                       {
                           MaxBufferSize = int.MaxValue,
                           MaxBufferPoolSize = int.MaxValue,
                           MaxReceivedMessageSize = int.MaxValue,

                           ReaderQuotas = new XmlDictionaryReaderQuotas()
                                              {
                                                  MaxArrayLength = int.MaxValue,
                                                  MaxStringContentLength = int.MaxValue
                                              },

                           TransferMode = TransferMode.Buffered,

                           Security = new NetTcpSecurity()
                                          {
                                              Mode = SecurityMode.Transport,
                                              Transport = new TcpTransportSecurity()
                                                              {
                                                                  ClientCredentialType = TcpClientCredentialType.Windows
                                                              }
                                          }
            };
        }
    }
}